package com.goods.business.converter;

import com.goods.common.model.business.Supplier;
import com.goods.common.vo.business.ProductVO;
import com.goods.common.vo.business.SupplierVO;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

public class SupplierConverter {

    /**
     * 转VO
     */

    public static SupplierVO supplierToSupplierVo(Supplier supplier){
        SupplierVO supplierVO = new SupplierVO();
        BeanUtils.copyProperties(supplier, supplierVO);
        return supplierVO;
    }

    /**
     * 转VOLIst
     *
     */
    public static List<SupplierVO> supplierToVoList(List<Supplier> suppliers){
        List<SupplierVO> supplierVOS= new ArrayList<>();
        SupplierVO supplierVO = new SupplierVO();

        if (!CollectionUtils.isEmpty(suppliers)){
            for (Supplier supplier : suppliers) {
                BeanUtils.copyProperties(supplier,supplierVO);
                supplierVOS.add(supplierVO);
            }
        }
        return supplierVOS;
    }
}
